package com.boardgame.gwt.service.operate.action;

import com.boardgame.common.entity.ResponseInfo;
import com.boardgame.gwt.data.GwtGameBoard;
import com.boardgame.gwt.service.operate.SyntaxBaseAction;
import com.boardgame.gwt.service.operate.SyntaxRequest;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 跳过自己的行动
 */
public class PassAction extends SyntaxBaseAction {
    @Override
    public Pattern getPattern() {
       return Pattern.compile("pass");
    }

    @Override
    public ResponseInfo action(GwtGameBoard gwtGameBoard, SyntaxRequest syntaxRequest, Matcher matcher) {
        super.action(gwtGameBoard, syntaxRequest, matcher);
        //还原移动步数
        this.gwtGameBoard.getCurrentPlayer().setMovedSurplus(this.gwtGameBoard.getCurrentPlayer().getMoveSpaces());
        //下一位玩家
        super.gwtGameBoard.setNextPlayer();
        return ResponseInfo.Success(null);
    }
}
